<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Paperclip</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Paperclip</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/attachment_rb.html">
                vendor/plugins/paperclip/lib/paperclip/attachment.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/callback_compatability_rb.html">
                vendor/plugins/paperclip/lib/paperclip/callback_compatability.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/geometry_rb.html">
                vendor/plugins/paperclip/lib/paperclip/geometry.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/interpolations_rb.html">
                vendor/plugins/paperclip/lib/paperclip/interpolations.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/matchers/have_attached_file_matcher_rb.html">
                vendor/plugins/paperclip/lib/paperclip/matchers/have_attached_file_matcher.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_content_type_matcher_rb.html">
                vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher_rb.html">
                vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_size_matcher_rb.html">
                vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_size_matcher.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/processor_rb.html">
                vendor/plugins/paperclip/lib/paperclip/processor.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/storage_rb.html">
                vendor/plugins/paperclip/lib/paperclip/storage.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/style_rb.html">
                vendor/plugins/paperclip/lib/paperclip/style.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/thumbnail_rb.html">
                vendor/plugins/paperclip/lib/paperclip/thumbnail.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip/upfile_rb.html">
                vendor/plugins/paperclip/lib/paperclip/upfile.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/paperclip/lib/paperclip_rb.html">
                vendor/plugins/paperclip/lib/paperclip.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The base module that gets included in ActiveRecord::Base. See the
documentation for <a
href="Paperclip/ClassMethods.html">Paperclip::ClassMethods</a> for more
useful information.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000007">interpolates</a>&nbsp;&nbsp;
      <a href="#M000009">log</a>&nbsp;&nbsp;
      <a href="#M000006">options</a>&nbsp;&nbsp;
      <a href="#M000008">run</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="Paperclip/CallbackCompatability.html" class="link">Paperclip::CallbackCompatability</a><br />
Module <a href="Paperclip/ClassMethods.html" class="link">Paperclip::ClassMethods</a><br />
Module <a href="Paperclip/Interpolations.html" class="link">Paperclip::Interpolations</a><br />
Module <a href="Paperclip/Shoulda.html" class="link">Paperclip::Shoulda</a><br />
Module <a href="Paperclip/Storage.html" class="link">Paperclip::Storage</a><br />
Module <a href="Paperclip/Upfile.html" class="link">Paperclip::Upfile</a><br />
Class <a href="Paperclip/Attachment.html" class="link">Paperclip::Attachment</a><br />
Class <a href="Paperclip/Geometry.html" class="link">Paperclip::Geometry</a><br />
Class <a href="Paperclip/Processor.html" class="link">Paperclip::Processor</a><br />
Class <a href="Paperclip/Style.html" class="link">Paperclip::Style</a><br />
Class <a href="Paperclip/Tempfile.html" class="link">Paperclip::Tempfile</a><br />
Class <a href="Paperclip/Thumbnail.html" class="link">Paperclip::Thumbnail</a><br />

    </div>

    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">VERSION</td>
          <td>=</td>
          <td class="context-item-value">&quot;2.3.1.1&quot;</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">interpolates</span><span class="method-args">(key, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/paperclip/lib/paperclip.rb, line 80</span>
80:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">interpolates</span> <span class="ruby-identifier">key</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
81:       <span class="ruby-constant">Paperclip</span><span class="ruby-operator">::</span><span class="ruby-constant">Interpolations</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">block</span>
82:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">log</span><span class="method-args">(message)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Log a paperclip-specific line. Uses ActiveRecord::Base.logger by default.
Set <a href="Paperclip.html#M000006">Paperclip.options</a>[:<a
href="Paperclip.html#M000009">log</a>] to false to turn off.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/paperclip/lib/paperclip.rb, line 130</span>
130:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log</span> <span class="ruby-identifier">message</span>
131:       <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">&quot;[paperclip] #{message}&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logging?</span>
132:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">options</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Provides configurability to <a href="Paperclip.html">Paperclip</a>. There
are a number of <a href="Paperclip.html#M000006">options</a> available,
such as:
</p>
<ul>
<li>whiny: Will raise an error if <a href="Paperclip.html">Paperclip</a> cannot
process thumbnails of an uploaded image. Defaults to true.

</li>
<li><a href="Paperclip.html#M000009">log</a>: Logs progress to the Rails <a
href="Paperclip.html#M000009">log</a>. Uses ActiveRecord&#8216;s logger, so
honors <a href="Paperclip.html#M000009">log</a> levels, etc. Defaults to
true.

</li>
<li>command_path: Defines the path at which to find the command line programs
if they are not visible to Rails the system&#8216;s search path. Defaults
to nil, which uses the first executable found in the user&#8216;s search
path.

</li>
<li>image_magick_path: Deprecated alias of command_path.

</li>
</ul>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/paperclip/lib/paperclip.rb, line 61</span>
61:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
62:       <span class="ruby-ivar">@options</span> <span class="ruby-operator">||=</span> {
63:         <span class="ruby-identifier">:whiny</span>             =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
64:         <span class="ruby-identifier">:image_magick_path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>,
65:         <span class="ruby-identifier">:command_path</span>      =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>,
66:         <span class="ruby-identifier">:log</span>               =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
67:         <span class="ruby-identifier">:log_command</span>       =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
68:         <span class="ruby-identifier">:swallow_stderr</span>    =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>
69:       }
70:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">run</span><span class="method-args">(cmd, params = &quot;&quot;, expected_outcodes = 0)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The <a href="Paperclip.html#M000008">run</a> method takes a command to
execute and a string of parameters that get passed to it. The command is
prefixed with the :command_path option from <a
href="Paperclip.html#M000006">Paperclip.options</a>. If you have many
commands to <a href="Paperclip.html#M000008">run</a> and they are in
different paths, the suggested course of action is to symlink them so they
are all in the same directory.
</p>
<p>
If the command returns with a result code that is not one of the
expected_outcodes, a PaperclipCommandLineError will be raised. Generally a
code of 0 is expected, but a list of codes may be passed if necessary.
</p>
<p>
This method can <a href="Paperclip.html#M000009">log</a> the command being
<a href="Paperclip.html#M000008">run</a> when <a
href="Paperclip.html#M000006">Paperclip.options</a>[:log_command] is set to
true (defaults to false). This will only <a
href="Paperclip.html#M000009">log</a> if logging in general is set to true
as well.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/paperclip/lib/paperclip.rb, line 97</span>
 97:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span> <span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">params</span> = <span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-identifier">expected_outcodes</span> = <span class="ruby-value">0</span>
 98:       <span class="ruby-identifier">command</span> = <span class="ruby-node">%Q[#{path_for_command(cmd)} #{params}]</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\s+/</span>, <span class="ruby-value str">&quot; &quot;</span>)
 99:       <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{command} 2&gt;#{bit_bucket}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Paperclip</span>.<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:swallow_stderr</span>]
100:       <span class="ruby-constant">Paperclip</span>.<span class="ruby-identifier">log</span>(<span class="ruby-identifier">command</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Paperclip</span>.<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:log_command</span>]
101:       <span class="ruby-identifier">output</span> = <span class="ruby-node">`#{command}`</span>
102:       <span class="ruby-keyword kw">unless</span> [<span class="ruby-identifier">expected_outcodes</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">$?</span>.<span class="ruby-identifier">exitstatus</span>)
103:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">PaperclipCommandLineError</span>, <span class="ruby-node">&quot;Error while running #{cmd}&quot;</span>
104:       <span class="ruby-keyword kw">end</span>
105:       <span class="ruby-identifier">output</span>
106:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>